package com.community.common.pojo.response;

import com.github.pagehelper.PageInfo;

import java.util.List;

public class LayuiPage {
    private String code;
    private String msg;
    private long count;
    private List<?> data;

    public LayuiPage() {
    }

    public LayuiPage(long count, List<?> data) {
        this.code = "0";
        this.msg = "数据加载成功";
        this.count = count;
        this.data = data;
    }

    public LayuiPage(List<?> list) {
        PageInfo<?> pageInfo = new PageInfo<>(list);
        this.code = "0";
        this.msg = "数据加载成功";
        this.count = pageInfo.getTotal();
        this.data = pageInfo.getList();
    }

    public LayuiPage(List<?> list, int i) {
        PageInfo<?> pageInfo = new PageInfo<>(list);
        this.code = "200";
        this.msg = "数据加载成功";
        this.count = pageInfo.getTotal();
        this.data = pageInfo.getList();
    }

    public LayuiPage(List<?> list, Object i) {
        this.code = "0";
        this.msg = "数据加载成功";
        this.count = list.size();
        this.data = list;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public long getCount() {
        return count;
    }

    public void setCount(long count) {
        this.count = count;
    }

    public List<?> getData() {
        return data;
    }

    public void setData(List<?> data) {
        this.data = data;
    }

    public static LayuiPage parsePage(List<?> list) {
        return new LayuiPage(list);
    }

    public static LayuiPage parsePageAll(List<?> list) {
        return new LayuiPage(list,null);
    }

    public static LayuiPage parsePage200(List<?> list) {
        return new LayuiPage(list, 1);
    }

}
